﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace _3D
{
    class Moinho
    {
        List<BlocoTxt> baseMoinho;
        Telhado cimaMoinho;
        Pa paMoinho;

        public Moinho(Vector3 position, GraphicsDevice graphics, Vector2 size, Camera camera, Texture2D baseTexture, Texture2D cimaTexture, Texture2D paTexture, float paAngle)
        {
            baseMoinho = new List<BlocoTxt>();
            cimaMoinho = new Telhado(size.Y * 2, graphics, camera, new Vector3(position.X + size.Y, 7 * size.Y, position.Z + size.Y), cimaTexture);
            
            if(paAngle == 0)
            paMoinho = new Pa(new Vector3(position.X + size.Y, 2 * 3 * size.Y, position.Z + 4*size.Y), new Vector2(10, 2), graphics, camera, paTexture, paAngle);

            else
            paMoinho = new Pa(new Vector3(position.X + size.Y, 2 * 3 * size.Y, position.Z - size.Y * 2), new Vector2(10, 2), graphics, camera, paTexture, paAngle);

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    for (int z = 0; z < 2; z++)
                    {
                       baseMoinho.Add(new BlocoTxt(size.Y, graphics, camera, baseTexture, new Vector3(2 * size.Y * i + position.X, 2 * size.Y * j + position.Y, position.Z + 2*size.Y * z)));
                    }
                }
            }
        }
        public void Update(Camera camera)
        {
            foreach (BlocoTxt t in baseMoinho)
                t.Update(camera);

            cimaMoinho.Update(camera);
            paMoinho.Update(camera);
        }
        public void Draw(GraphicsDevice d)
        {
            foreach (BlocoTxt t in baseMoinho)
                t.Draw(d);

            cimaMoinho.Draw(d);
            paMoinho.Draw(d);
        }
    }
}
